package com.learning.rat.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.learning.rat.dao.UserMapper;
import com.learning.rat.service.IUserService;
import com.learning.rat.web.bean.User;
@Service("userService")
public class UserServiceImpl implements IUserService{

	@Autowired
	private UserMapper mapper;

	public User findUserById(String userId) {
		
		// TODO Auto-generated method stub
		return mapper.findUserById(userId);
	}

	public List<User> findUsers(int offset, int count) {
		// TODO Auto-generated method stub
		return mapper.findUsers(offset, count);
	}
	@Transactional
	public int updateusername(String host) throws Exception{
		int flag = mapper.updateusername(host);
//		throw new RuntimeException("happened a new exception!!!");
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.learning.rat.service.IUserService#pkgtest()
	 * 
	 * oracle 调用存储过程
	 */
	@Transactional
	public void pkgtest() {
		// TODO Auto-generated method stub
		
		// 组装参数
		Map<String, Object> itemsMap = new HashMap<String, Object>();
		itemsMap.put("in_testid1", 123);
		itemsMap.put("in_testid2", "zhangmintest");
		 mapper.pkgtest1(itemsMap);
		System.out.println("===============");
	}
}
